#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
class Solution{
public:
	// 1,2,3,4,5,6
	// 直接法
	void rotate(vector<int>& nums, int k){
		int len = nums.size();
		int realk = k % len;
		vector<int> a;
		int i = 0;
		while(i < len){
			a.push_back(nums.at(abs((len-realk)%len)));
			i++;
			realk--;
		}
		nums.assign(a.begin(), a.end());
	}
	
	
};

int main(){
	vector<int> nums = {1,2,3,4,5,6,7};
	int k = 2;
	Solution so;
	so.rotate(nums, k);
	for(auto i : nums){
		cout << i << " ";
	}
	cout << endl;
	return 0;
}